Skip to content

Conversation

@ephraimbuddy
Copy link
Contributor

Enforces serialization of DAGs before creating DagRuns and TaskInstances.

The changes include:

  • Making dag_version_id a required parameter in TaskInstance constructor
  • Migrating the dag_version_id column in TaskInstance to be non-nullable
  • Adding a check in _create_orm_dagrun to raise AirflowException if dag is not serialized
  • Updating tests to ensure DAGs are properly serialized before creating DagRuns

This prevents running runs with missing serialized DAG versions.

@ephraimbuddy ephraimbuddy force-pushed the make-ti-dag-version-id-non-nullable2 branch from 20c6e75 to 08bfa28 Compare May 20, 2025 17:14
@ephraimbuddy ephraimbuddy force-pushed the make-ti-dag-version-id-non-nullable2 branch from 9d3fc74 to 63eb72b Compare May 21, 2025 15:28
@ephraimbuddy ephraimbuddy force-pushed the make-ti-dag-version-id-non-nullable2 branch 2 times, most recently from aad0a5f to 80439a1 Compare May 21, 2025 17:35
@ephraimbuddy ephraimbuddy requested a review from mobuchowski as a code owner May 22, 2025 17:27
@ephraimbuddy ephraimbuddy force-pushed the make-ti-dag-version-id-non-nullable2 branch 2 times, most recently from 5409839 to 616e0a1 Compare May 24, 2025 22:18
@ephraimbuddy ephraimbuddy force-pushed the make-ti-dag-version-id-non-nullable2 branch from 616e0a1 to 070f7a3 Compare May 25, 2025 10:55
@ephraimbuddy ephraimbuddy force-pushed the make-ti-dag-version-id-non-nullable2 branch from 564ac88 to f3c6444 Compare July 8, 2025 15:28
@ephraimbuddy ephraimbuddy merged commit 7ea7fcd into apache:main Jul 8, 2025
193 of 194 checks passed
@ephraimbuddy ephraimbuddy deleted the make-ti-dag-version-id-non-nullable2 branch July 8, 2025 17:55
HsiuChuanHsu pushed a commit to HsiuChuanHsu/airflow that referenced this pull request Jul 10, 2025
* Make dag_version_id in TI non-nullable

Enforces proper serialization of DAGs before creating DagRuns and TaskInstances.
The changes include:

 - Making dag_version_id a required parameter in TaskInstance constructor
 - Migrating the dag_version_id column in TaskInstance to be non-nullable
 - Adding a check in _create_orm_dagrun to raise AirflowException if dag is not serialized
 - Updating tests to ensure DAGs are properly serialized before creating DagRuns

This prevents running runs with missing serialized DAG versions.

* fixup! Make dag_version_id in TI non-nullable

* Fix tests for some providers

* fixup! Fix tests for some providers

* fixup! fixup! Fix tests for some providers

* more test fixes

* fixup! more test fixes

* fixup! fixup! more test fixes

* Update more tests

* fixup! Update more tests

* fixup! fixup! Update more tests

* fixup! fixup! fixup! Update more tests

* fixup! fixup! fixup! fixup! Update more tests

* fixup! fixup! fixup! fixup! fixup! Update more tests

* Add compat for MockedTaskInstance

* fixup! Add compat for MockedTaskInstance

* fixup! fixup! Add compat for MockedTaskInstance

* fix system test

* fixup! fix system test

* A fix for kube integration tests

* Update the expected TIs from test multiple versions number file

* fix incorrect imports

* fix time delta async test

* Remove non working kube test fix

* Fix task sdk test

* Add cadwyn migration and fix some tests

* fix some provider tests

* Add data migration before migrating dag_version_id

* Update test, TaskInstanceResponse and fix assert dag_version in task_command.py

* Resolve conflicts

* Fix test

* Fix more tests

* fixup! fixup! Fix more tests

* Fix bad rebase

* update fab www-hash

* Fix conflicts

* Fix MappedTaskInstancedata

* add dag_version_id to a new test

* Fix fab www hash
stephen-bracken pushed a commit to stephen-bracken/airflow that referenced this pull request Jul 15, 2025
* Make dag_version_id in TI non-nullable

Enforces proper serialization of DAGs before creating DagRuns and TaskInstances.
The changes include:

 - Making dag_version_id a required parameter in TaskInstance constructor
 - Migrating the dag_version_id column in TaskInstance to be non-nullable
 - Adding a check in _create_orm_dagrun to raise AirflowException if dag is not serialized
 - Updating tests to ensure DAGs are properly serialized before creating DagRuns

This prevents running runs with missing serialized DAG versions.

* fixup! Make dag_version_id in TI non-nullable

* Fix tests for some providers

* fixup! Fix tests for some providers

* fixup! fixup! Fix tests for some providers

* more test fixes

* fixup! more test fixes

* fixup! fixup! more test fixes

* Update more tests

* fixup! Update more tests

* fixup! fixup! Update more tests

* fixup! fixup! fixup! Update more tests

* fixup! fixup! fixup! fixup! Update more tests

* fixup! fixup! fixup! fixup! fixup! Update more tests

* Add compat for MockedTaskInstance

* fixup! Add compat for MockedTaskInstance

* fixup! fixup! Add compat for MockedTaskInstance

* fix system test

* fixup! fix system test

* A fix for kube integration tests

* Update the expected TIs from test multiple versions number file

* fix incorrect imports

* fix time delta async test

* Remove non working kube test fix

* Fix task sdk test

* Add cadwyn migration and fix some tests

* fix some provider tests

* Add data migration before migrating dag_version_id

* Update test, TaskInstanceResponse and fix assert dag_version in task_command.py

* Resolve conflicts

* Fix test

* Fix more tests

* fixup! fixup! Fix more tests

* Fix bad rebase

* update fab www-hash

* Fix conflicts

* Fix MappedTaskInstancedata

* add dag_version_id to a new test

* Fix fab www hash
Comment on lines +280 to +282
dag = DagBag().get_dag("test_mapped_classic")
dag.sync_to_db()
SerializedDagModel.write_dag(dag, bundle_name="testing")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has introduced a bug. This was the clue where we had to change the test

ephraimbuddy added a commit to astronomer/airflow that referenced this pull request Aug 11, 2025
This is alternative to apache#53820. Here we make the TI.dag_version_id
nullable on the database level. it's still enforced in code
ephraimbuddy added a commit to astronomer/airflow that referenced this pull request Aug 11, 2025
This is alternative to apache#53820. Here we make the TI.dag_version_id
nullable on the database level. it's still enforced in code
ephraimbuddy added a commit to astronomer/airflow that referenced this pull request Aug 12, 2025
This is alternative to apache#53820. Here we make the TI.dag_version_id
nullable on the database level. it's still enforced in code
ephraimbuddy added a commit to astronomer/airflow that referenced this pull request Aug 12, 2025
ephraimbuddy added a commit that referenced this pull request Aug 12, 2025
* Partially revert #50825 on database level

This is alternative to #53820. Here we make the TI.dag_version_id
nullable on the database level. it's still enforced in code

* fixup! Partially revert #50825 on database level
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API area:CLI area:db-migrations PRs with DB migration area:Scheduler including HA (high availability) scheduler area:serialization area:task-sdk area:Triggerer full tests needed We need to run full set of tests for this PR to merge kind:documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants